﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using WorkoutTracker.ViewModelNameSpace;

namespace WorkoutTracker
{
    public partial class AddWorkoutPage : PhoneApplicationPage
    {
        private WorkoutViewModel wvm;

        public AddWorkoutPage()
        {
            InitializeComponent();
            wvm = new WorkoutViewModel();
        }

        // When page is navigated to set data context to selected item in list
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            wvm.CreateNewWorkout();
            this.DataContext = wvm.WorkoutToHandle;
        }

        private void Button_Add_Click(object sender, RoutedEventArgs e)
        {
            wvm.SaveWorkout();
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }

    }
}